package hoowin.common.action;

import hoowin.common.model.FileItem;
import hoowin.common.service.FileService;

import java.io.File;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class Upload extends ActionSupport {
	private FileItem fi = new FileItem();
	private FileService fileService;
	private int fileId;
	
	public String execute(){
		this.setFileId(fileService.saveFile(fi));
		return SUCCESS;
	}
	
	public void setFiledata(File filedata) {
		fi.setItem(filedata);
	}
	public void setFiledataFileName(String filedataFileName) {
		fi.setItemFileName(filedataFileName);
	}
	public void setFiledataContentType(String filedataContentType) {
		fi.setItemContentType(filedataContentType);
	}
	public void setSize(int size) {
		fi.setSize(size);
	}
	public void setKey(String key) {
		fi.setKey(key);
	}
	public void setFileService(FileService fileService) {
		this.fileService = fileService;
	}
	public FileService getFileService() {
		return fileService;
	}

	public void setFileId(int fileId) {
		this.fileId = fileId;
	}

	public int getFileId() {
		return fileId;
	}
}
